package com.czkt.springboot_mybatis_test.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.czkt.springboot_mybatis_test.entity.Storage;
import com.czkt.springboot_mybatis_test.entity.vo.StorageProduct;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2024-06-18
 */
@Mapper
public interface StorageMapper extends BaseMapper<Storage> {
    @Select("select count(*) from storage s inner join crm.product p on p.prod_id = s.stk_prod_id where s.stk_warehouse like concat('%',#{stkWarehouse},'%')  and p.prod_name like concat('%',#{prodName},'%') ")
    Integer StorageAndProductCount(@Param("stkWarehouse") String stkWarehouse,@Param("prodName") String prodName);

    @Select("select * from storage s inner join crm.product p on p.prod_id = s.stk_prod_id where s.stk_warehouse like concat('%',#{stkWarehouse},'%')  and p.prod_name like concat('%',#{prodName},'%') limit #{pageIndex},#{pageSize}")
    List<StorageProduct> selectStorageAndProduct(@Param("stkWarehouse") String stkWarehouse,@Param("prodName") String prodName,@Param("pageIndex") Integer pageIndex,@Param("pageSize") Integer pageSize);
}
